package dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import pojo.CentroMaterial;

import util.ConexaoPPCP;

public class CentroMaterialDao {
	
	public List listarCentroMaterial() throws SQLException, ClassNotFoundException{
        ArrayList <CentroMaterial>lista = new ArrayList();		
		Connection conexao = ConexaoPPCP.getConexaoPPCP();
		String sql = "select * from CentroMaterial";
		Statement st = conexao.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
		ResultSet rs = st.executeQuery(sql);
		//conexao.close();
		while (rs.next()){
			CentroMaterial centro = new CentroMaterial();
			centro.setId(rs.getString("id"));
			centro.setDescricao(rs.getString("descricao"));
			lista.add(centro);
		}
		return lista;
	}
}
